<%@ page import="cn.school.util.MybatisUtil" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="cn.school.dao.SubjectMapper" %>
<%@ page import="cn.school.entity.Subject" %>
<%@ page import="java.util.List" %>
<%--
@叫指令，page:导入类
         taglib:导入
         include:导入其他jsp
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2022-02-27
  Time: 8:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>课程信息</title>
</head>
<body>
<%!
      public double pi=3.15;
      public String toUp(String s){
          return s==null?"":s.toUpperCase();
      }
%>
    <h2>所有课程信息</h2>
    <%
        SqlSession session1 = MybatisUtil.get();
        SubjectMapper mapper = session1.getMapper(SubjectMapper.class);
        List<Subject> subjects = mapper.findALL();
        MybatisUtil.close(session1);
        ///out.println();
        // java.io.Writer的对象
        //内置对象
        //out输出信息到前端
        out.print("<h3>这里是全部的课程信息</h3>");
    %>

<a href="addsubject.jsp">添加新课程</a>
<table border="1" cellpadding="0" cellspacing="0">
    <tr><th>编号</th><th>课程名</th><th>课时</th><th>所属年级</th></tr>
    <%
     for(Subject s:subjects){
    %>
    <tr>
        <td><%= s.getId()  %></td>
        <td><%=toUp(s.getSubjectname())%></td>
        <td><%=s.getClasshour()%></td>
        <td><%=s.getGradeId()%></td>
    </tr>
    <%}%>
</table>
</body>
</html>
